﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[RequireComponent(typeof(Rigidbody))]//挂脚本的时候自动挂上刚体组件
public class D06_RigidBody3 : MonoBehaviour
{
    //当触发器进入
    private void OnTriggerEnter(Collider other) //other就是对方的碰撞器
    {
        print("进入");
        other.ChangeColor(Color.red);
    }
    //当触发器停留
    private void OnTriggerStay(Collider other)
    {
        print("停留");
    }
    //当触发器离开
    private void OnTriggerExit(Collider other)
    {
        print("离开");
        other.ChangeColor(Color.white);
    }
}